//
//  AppDelegate+AppUI.m
//  taotaoshi
//
//  Created by 林煜南 on 2017/11/27.
//  Copyright © 2017年 Dongguan taotao network technology co. LTD. All rights reserved.
//

#import "AppDelegate+AppUI.h"

@implementation AppDelegate (AppUI)

- (void)setAppUI
{
    
    // 1.画图片
    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextFillRect(context, rect);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    // 2.更改系统导航栏背景图
    [[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:0];
    
    // 3.更改中间文字样式
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:FONT(18),NSForegroundColorAttributeName:MAIN_BACKCOLOR}];
    
    [[UINavigationBar appearance] setTintColor:MAIN_BACKCOLOR];
    

    // 更改TextField输入框光标颜色
    [[UITextField appearance] setTintColor:GRAYTEXT_COLOR];
    
    [[UISearchBar appearance] setTintColor:GRAYTEXT_COLOR];
    
    // 更改TextView输入框光标颜色
    [[UITextView appearance] setTintColor:GRAYTEXT_COLOR];
    
    //启用键盘自动处理
    [IQKeyboardManager sharedManager].enable = YES;
    //启用键盘自动收起功能
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
    
    // 更改字体大小
    [[UILabel appearance]setFont:[UIFont systemFontOfSize:14]];
    //适配iOS11
    [[UITableView appearance] setLayoutMargins:UIEdgeInsetsZero];
    if (@available(iOS 11.0, *)){
        [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
        
    }
    UITableView.appearance.estimatedRowHeight = 0;
    UITableView.appearance.estimatedSectionFooterHeight = 0;
    UITableView.appearance.estimatedSectionHeaderHeight = 0;
    
}

@end
